﻿using System;
using System.Collections.Generic;
using System.Xml;

//自定义命名空间
using DreamCube.Foundation.Basic.Utility;

namespace AutoCompile.UI
{
    public static class ProjectHelper
    {
        /// <summary>
        /// 获取项目的所有配置
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static List<String> GetCondition(String filePath)
        {
            String xmlData = filePath.ReadText();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xmlData);
            List<String> conditions = new List<String>();
            if (doc != null)
            {
                XmlNamespaceManager nm = new XmlNamespaceManager(doc.NameTable);
                nm.AddNamespace("abc", "http://schemas.microsoft.com/developer/msbuild/2003");
                XmlNodeList propertyNodes = doc.SelectNodes("/abc:Project/abc:PropertyGroup", nm);
                if (propertyNodes != null && propertyNodes.Count > 0)
                {
                    foreach (XmlNode node in propertyNodes)
                    {
                        XmlAttribute attr = node.Attributes["Condition"];
                        if (attr != null) conditions.Add(attr.InnerText);
                    }
                }
            }
            return conditions;
        }
    }
}
